package com.busines.dto;

import com.fasterxml.jackson.annotation.JsonInclude;

/**     
 * 类描述：基础传输对象
 * 创建人：发动机  
 */
public class BaseDto {
    private int ret;// 结果状态码
    private String msg;// 结果信息
    private Integer timeStamp;// 返回时间戳
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Object obj ; //数据
    public enum RetConstant {
        // 共有返回值
        OK(0,"处理成功"),              // 处理成功
        FAIL(100,"处理失败"),          // 处理失败
        SERVER_ERROR(500,"服务器异常"),	// 服务器异常

        PARAM_ERROR(505,"参数错误"),	// 参数错误
    	
    	;
        private final String msg;
        private final int value;
        RetConstant(int value,String msg) {
            this.value = value;
            this.msg = msg;
        }
        public int getValue() {
            return value;
        }
		public String getMsg() {
			return msg;
		}
        
    }
    public BaseDto() {
        ret = 0;
        msg = "ok";
    }
    public int getRet() {
        return ret;
    }
    public void setRet(int ret) {
        this.ret = ret;
    }
    public String getMsg() {
        return msg;
    }
    public void setMsg(String msg) {
        this.msg = msg;
    }
    public Integer getTimeStamp() {
        return timeStamp == null ? (int)(System.currentTimeMillis()/1000):timeStamp;
    }
    public void setTimeStamp(Integer timeStamp) {
        this.timeStamp = timeStamp;
    }
	public Object getObj() {
		return obj;
	}
	public void setObj(Object obj) {
		this.obj = obj;
	}
	@Override
	public String toString() {
		return "BaseDto [ret=" + ret + ", msg=" + msg + ", timeStamp=" + timeStamp + ", obj=" + obj + "]";
	}
	
	public void setDefeaultMsgError(int ret,String msg){
		this.ret = ret;
		this.msg = msg;
	}
	public void serverMsgError(){
		this.ret = RetConstant.SERVER_ERROR.getValue();
		this.msg = RetConstant.SERVER_ERROR.getMsg();
	}
}
